﻿using System.Collections.Generic;
using System.Web;
using AFT.Parking.Foundation.Configuration;
using AFT.Parking.Entity.Menus;

namespace AFT.Parking.Bizlogic.Menus
{
    public class MenusBiz
    {
        private const string XmlPath = "/Menus.xml";

        private static List<FirstMenu> _menus;
        private static object o = new object();

        public static List<FirstMenu> Menus
        {
            get
            {
                if (_menus == null)
                {
                    lock (o)
                    {
                        if (_menus == null)
                        {
                            var config = new ConfigRW<List<FirstMenu>>
                            {
                                ConfigFileFullPath = HttpContext.Current.Server.MapPath(XmlPath)
                            };
                            _menus = config.LoadFromFile();
                        }
                    }
                }
                return _menus;
            }
        }
    }
}
